/**
 * File Comment: Ita a GUI
 */
package edu.gatech.oad.project.presentation;
//$codepro.audit.disable
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * This class is a panel that allows the user
 * to interact with the GUI by providing a
 * home screen.
 * 
 * @author Group 17
 * @version 1
 */
public class PatientHome extends JPanel {
  
  /**
   * Field driver: holds the Driver connected to the GUI
   */
  private Driver driver;
  
  /**
   * Field lblPatientHome: label
   */
  public JLabel lblPatientHome;
  
  /**
   * Field btnScheduleAnAppointment: schedule appointment button
   */
  public JButton btnScheduleAnAppointment;
  
  /**
   * Field btnCancelAnAppointment: cancel an appointment button
   */
  public JButton btnCancelAnAppointment;
  
  /**
   * Field btnViewMedicalHistory: view medical history button
   */
  public JButton btnViewMedicalHistory;
  
  /**
   * Field btnLogOut: log out button
   */
  public JButton btnLogOut;

 /**
  * Constructor.
  * 
  * @param driver the Driver connected to the GUI
  */
 public PatientHome(Driver driver) {
   this.driver = driver;
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
  gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);
  
  lblPatientHome = new JLabel("Patient Home");
  lblPatientHome.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
  GridBagConstraints gbc_lblPatientHome = new GridBagConstraints();
  gbc_lblPatientHome.insets = new Insets(0, 0, 5, 0);
  gbc_lblPatientHome.gridx = 4;
  gbc_lblPatientHome.gridy = 1;
  add(lblPatientHome, gbc_lblPatientHome);
  
  btnScheduleAnAppointment = new JButton("Schedule an Appointment");
  btnScheduleAnAppointment.addActionListener(new ButtonListener1(this));
  GridBagConstraints gbc_btnScheduleAnAppointment = new GridBagConstraints();
  gbc_btnScheduleAnAppointment.insets = new Insets(0, 0, 5, 0);
  gbc_btnScheduleAnAppointment.gridx = 4;
  gbc_btnScheduleAnAppointment.gridy = 3;
  add(btnScheduleAnAppointment, gbc_btnScheduleAnAppointment);
  
  btnCancelAnAppointment = new JButton("Cancel an Appointment");
  btnCancelAnAppointment.addActionListener(new ButtonListener2(this));
  GridBagConstraints gbc_btnCancelAnAppointment = new GridBagConstraints();
  gbc_btnCancelAnAppointment.insets = new Insets(0, 0, 5, 0);
  gbc_btnCancelAnAppointment.gridx = 4;
  gbc_btnCancelAnAppointment.gridy = 4;
  add(btnCancelAnAppointment, gbc_btnCancelAnAppointment);
  
  btnViewMedicalHistory = new JButton("View Medical History");
  btnViewMedicalHistory.addActionListener(new ButtonListener3(this));
  GridBagConstraints gbc_btnViewMedicalHistory = new GridBagConstraints();
  gbc_btnViewMedicalHistory.insets = new Insets(0, 0, 5, 0);
  gbc_btnViewMedicalHistory.gridx = 4;
  gbc_btnViewMedicalHistory.gridy = 5;
  add(btnViewMedicalHistory, gbc_btnViewMedicalHistory);
  
  btnLogOut = new JButton("Log Out");
  btnLogOut.addActionListener(new ButtonListener4(this));
  GridBagConstraints gbc_btnLogOut = new GridBagConstraints();
  gbc_btnLogOut.gridx = 4;
  gbc_btnLogOut.gridy = 6;
  add(btnLogOut, gbc_btnLogOut);
 } // end constructor method
 
 /**
  * Get the Driver.
  * 
  * @return the Driver connected to the GUI
  */
 public Driver getDriver()
 {
   return this.driver;
 } // end getDriver method

 /**
  * This private inner class implements ActionListener for btnScheduleAnAppointment.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener1 implements ActionListener
 {
   /**
    * Field home: the PatientHome being used
    */
   private PatientHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the PatientHome being used
    */
   private ButtonListener1(PatientHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new AppScheduler(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener1 class
 
 /**
  * This private inner class implements ActionListener for btnCancelAnAppointment.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener2 implements ActionListener
 {
   /**
    * Field home: the PatientHome being used
    */
   private PatientHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the PatientHome being used
    */
   private ButtonListener2(PatientHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new CancelApp(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener2 class
 
 /**
  * This private inner class implements ActionListener for btnViewMedicalHistory.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener3 implements ActionListener
 {
   /**
    * Field home: the PatientHome being used
    */
   private PatientHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the PatientHome being used
    */
   private ButtonListener3(PatientHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new PatientMedHistory(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener3 class
 
 /**
  * This private inner class implements ActionListener for btnLogOut.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener4 implements ActionListener
 {
   /**
    * Field home: the PatientHome being used
    */
   private PatientHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the PatientHome being used
    */
   private ButtonListener4(PatientHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new LogIn(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener4 class
} // end PatientHome class